<script type="text/javascript"
     src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<head>
    <link rel="stylesheet" href="stylesheet_TMATS.css">
</head>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<title>
    T-MATS: Help for Linearize Library Block
</title>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<body>
    <h1>
      T-MATS: Linearize Library Block
    </h1>
<hr>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="purpose">
        Purpose
</div>

<p>
    This block is used to linearize a given system
    by determining the state-space equation for the system.
</p>

<br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="background">
        Background
</div>

<p>
    The goal of this block is to perform a transformation of the inputs in
    order to determine a linear relationship between the inputs and outputs.
    To determine the linearization of the system, this block uses the following
    state-space equations:

    $$\dot{x} = A*(x - x_0) + B*(u - u_0)$$
    $$(y - y_0) = C*(x - x_0) + D*(u - u_0)$$

    In the above equations, the variables <i>x<sub>0</sub></i>, <i>u<sub>0</sub></i>,
    , and <i>y<sub>0</sub></i> are initial conditions,
    while the variables <i>A</i>, <i>B</i>, <i>C</i>, and <i>D</i> are
    matricies determined by these equations.
</p>
<p>
    Matrix/vector sizes are specified as follows:<br>

    <ul>
        <li>xdot : mx1
        <li>x : mx1
        <li>y : px1
        <li>u : nx1
        <li>A : mxm
        <li>B : mxn
        <li>C : pxm
        <li>D : pxn
    </ul>

    During operation, each plant state (<i>x</i>) and input (<i>u</i>)
    will be set to an initial condition and then perturbed separately.
    The perturbed inputs and system effects are compared against the
    starting value to calculate the <i>A</i>, <i>B</i>, <i>C</i>, and <i>D</i>
    matricies.
</p>
<p>
    For an example of how to use this block within a simulation, run the
    TMATS_Run_Example.m script, select the option to view the Linearization
    examples, then select the option for State Space Recalculation or forJT9D
    Single Point Linearization to see how this block can be used within a
    simulation.
</p>
<br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="instructions">
        Instructions
</div>

<p>
    To use this block:
    <ul>
        <li> Connect the input parameters to the corresponding places on the
        block.
        <ul>
            <li><i>Note:</i> The inputs <i>xdot</i> and <i>y</i> should come
            from the system that is being linearized.
        </ul>
        <li> Connect the input command to enable the block.
        <li> Connect the outputs to the next blocks in the simulation. 0 value outputs are not needed for basic operation,
        but are present if a user needs them for an advanced setup.
        <li> Double click the block and specify the following:
        <ul>
            <li>Perturbation values for <i>x</i> and <i>u</i>
            <li>Number of expected <i>y</i> values
        </ul>
    </ul>
</p>
<p>
    If this block needs to be reset, input a 1 to "Reset" input.
    For more information about each input, output, and mask variable, see
    the tables below.
</p>

<br><hr><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="inputs">
        Linearize Inputs
</div>

<table>
    <tr><th> Input </th><th>Description</th></tr>
    <tr><td>x0</td><td>Value of x to be linearized around, initial x (mx1)</td></tr>
    <tr><td>u0</td><td>Value of u to be linearized around, initial u (nx1)</td></tr>
    <tr><td>xdot</td><td>Delta x. Determined from x perturbation (mx1)</td></tr>
    <tr><td>y</td><td>System output data (px1)</td></tr>
    <tr><td>Enable</td><td>Enables the linearize block. If block is disabled
        x0 and u0 will be passed through to outputs x and u, respectively </td></tr>
    <tr><td>Reset</td><td>Reset the linearize block</td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="outputs">
        Linearize Outputs
</div>

<table>
    <tr><th> Output </th><th> Description </th></tr>
    <tr><td>ABCD_matrices</td><td>Bus containing the ABCD matrices</td></tr>
    <tr><td>x</td><td>Current value of x, used for perturbing the system (mx1)</td></tr>
    <tr><td>u</td><td>Current value of u, used for perturbing the system (nx1)</td></tr>
    <tr><td>xdot_0</td><td>xdot value when x = x0 and y = y0 (mx1), note: should be zero.</td></tr>
    <tr><td>y0</td><td>y value when x = x0 and y = y0 (px1)</td></tr>
    <tr><td>Iter</td><td>Number of time Linerize block has run</td></tr>
    <tr><td>Active</td><td>Linearize block is actively running</td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="maskvars">
        Linearize Mask Variables
</div>

<table>
    <tr><th> Mask Variable </th><th> Description </th></tr>
    <tr><td>N_XPer_M</td><td>Perturbation values for each x that will occur r times.(rxm)</td></tr>
    <tr><td>N_UPer_M</td><td>Perturbation values for each u that will occur r times.(rxn)</td></tr>
    <tr><td>N_Y_M</td><td>Number of y values or p above </td></tr>
</table>

<br><hr><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class = "errors">
    Potential Errors
</div>
<p>
When using this block, a warning will occur if the vectors do not have the
proper sizes. For example, a warning would appear if the sizes of the vectors
for <i>x0</i> and <i>xdot</i> did not match. Additionally, since this block
is used to linearize a system around a certain operating point, if the initial
conditions are not near the operating point, the system may become unstable
or fail.

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
</body>